﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;

namespace AlgorithmBox.Classes
{
	class NativeMethods
	{
		//[DllImport("dwmapi", PreserveSig=false)]
		//static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS margins);

		//[DllImport("dwmapi", PreserveSig=false)]
		//static extern bool DwmIsCompositionEnabled();

		public static bool ExtendGlass(Window window, Thickness thickness)
		{
			//MessageBox.Show(Environment.OSVersion.Platform.ToString());
			//TODO: control OS version

			//if (!DwmIsCompositionEnabled())
			//    return false;

			//IntPtr hWnd = new WindowInteropHelper(window).Handle;
			//if (hWnd == IntPtr.Zero)
			//    return false;

			//window.Background = Brushes.Transparent;
			//HwndSource.FromHwnd(hWnd).CompositionTarget.BackgroundColor = Colors.Transparent;

			//MARGINS margins = new MARGINS(thickness);
			//DwmExtendFrameIntoClientArea(hWnd, ref margins);

			return true;
		}
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct MARGINS
	{
		public int Left, Right, Top, Bottom;

		public MARGINS(Thickness thickness)
		{
			this.Left = (int)thickness.Left;
			this.Right = (int)thickness.Right;
			this.Top = (int)thickness.Top;
			this.Bottom = (int)thickness.Bottom;
		}
	}
}
